package com.hengpeng.itfin.persist.impl;

import java.util.Date;

import org.springframework.stereotype.Repository;

import com.hengpeng.common.persist.AbstractDao;
import com.hengpeng.common.util.DateTimeUtil;
import com.hengpeng.itfin.persist.RebateDao;
import com.hengpeng.itfinbase.en.RewardRebateStatus;
import com.hengpeng.itfinbase.persist.RewardRebate;

@Repository
public class RebateDaoImpl extends AbstractDao<RewardRebate> implements RebateDao {

    @Override
    public int updateStatus(long userId, RewardRebateStatus oldStatus, RewardRebateStatus newStatus, Date updateTime,
            Date payTime) {
        return super.exeNamedQuery("rebate.updateStatus", new Object[] { newStatus, updateTime, payTime, userId,
                oldStatus, DateTimeUtil.addDate(DateTimeUtil.getPreviousStartDate(), 1) });
    }

    @Override
    public int activeByReferenceId(String referenceId, Date activetime) {
        return super.exeNamedQuery("rebate.active", new Object[] { activetime, RewardRebateStatus.CANPAY, referenceId,
                RewardRebateStatus.UNACTIVE });
    }
}
